package college;

import javax.jdo.annotations.*;
import java.util.*;
import department.Department;

@PersistenceCapable
public class College {
	@PrimaryKey
    @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
	private Long colId;
	
	@Persistent
	private String colName;
	
	@Persistent(mappedBy = "college")
	@Element(dependent = "true") 
	private List <Department> dep;
	
	public College(String name){
		this.colName = name;
	}
	
	public College(){
		this.colName = "NA";
	}
	
	public Long getId(){
		return this.colId;
	}
	
	public String getName(){
		return this.colName;
	}
	
	public void setName(String name){
		this.colName = name;
	}
	
	public List<Department> getAllDep(){
		List<Department> temp = new ArrayList<Department>();
		for(Department dep : this.dep){
			temp.add(dep);
		}
		return temp;
	}
	
	public void addDep(String name,College col){
		dep.add(new Department(name,col));
	}
}